<div class="widget">
    <div class="title"><h2><span>My playlist</span></h2></div>
    <div class="content">
        <?php
        if($isLoggedIn):
        ?>
        <div class="styled-select">
            <select name="list_playlist" id="user_<?=$_SESSION['user_id']?>">
                <option value="">---Chọn playlist---</option>
                <?=$list_playlist;?>
            </select>
        </div>
        <a href="#" id="playlist_add" title="Thêm playlist"><div class="playlist_add"></div></a>
        <a href="#" id="playlist_remove" title="Xóa playlist"><div class="playlist_remove"></div></a>
        <script type="text/javascript">
            $(document).ready(function() {
                if($("select[name='list_playlist']").val() == '')
                    $("#playlist_remove").hide();
                user = $("select[name='list_playlist']").attr('id');
                user_id = user.replace('user_','');
                $("#playlist_add").click(function() {
                    playlist_add(user_id);
                    $("#playlist_remove").show();
                    return false;
                });

                $("select[name='list_playlist']").change(function() {
                    if($("select[name='list_playlist']").val() != '')
                        $("#playlist_remove").show();
                    else
                        $("#playlist_remove").hide();
                    playlist_id = $("select[name='list_playlist']").val();
                    playlist_change(playlist_id);
                });

                $("#playlist_remove").click(function() {
                    a = confirm('Bạn muốn xóa playlist này ? ');
                    if(a) {
                        playlist_id = $("select[name='list_playlist']").val();
                        playlist_remove(playlist_id);
                        $("#playlist_remove").hide();
                        return false;
                    }
                    return false;
                });
            });
        </script>
        <?php endif; ?>
        <div style="padding-top:3px;clear:both">
            <ul class="list_songs" id="playlist_field">
                <?=$playlist_HTML;?>

            </ul>
        </div>
        <?=$play_ALL;?>
        <p id="error_pl"></p>
    </div>
</div>
